<?php

/**
 * This is the model class for table "tbl_glucometers_outpatients_records".
 *
 * The followings are the available columns in table 'tbl_glucometers_outpatients_records':
 * @property string $pk_glucometer_outpatient_record_id
 * @property string $fk_outpatient_id
 * @property string $fk_glucometer_outpatient_id
 * @property integer $record_type
 * @property integer $update_record_type
 * @property integer $outpatient_blood_suger_value
 * @property integer $temperature
 * @property string $correction_code
 * @property integer $record_time_quantum
 * @property string $measure_time
 * @property string $update_measure_time
 * @property string $create_time
 * @property string $update_time
 */
class TblGlucometersOutpatientsRecords extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tbl_glucometers_outpatients_records';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('fk_glucometer_outpatient_id, record_type, update_record_type, outpatient_blood_suger_value, record_time_quantum, measure_time, update_measure_time, create_time, update_time', 'required'),
			array('record_type, update_record_type, outpatient_blood_suger_value, temperature, record_time_quantum', 'numerical', 'integerOnly'=>true),
			array('fk_outpatient_id, fk_glucometer_outpatient_id', 'length', 'max'=>20),
			array('correction_code', 'length', 'max'=>50),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('pk_glucometer_outpatient_record_id, fk_outpatient_id, fk_glucometer_outpatient_id, record_type, update_record_type, outpatient_blood_suger_value, temperature, correction_code, record_time_quantum, measure_time, update_measure_time, create_time, update_time', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'pk_glucometer_outpatient_record_id' => 'Pk Glucometer Outpatient Record',
			'fk_outpatient_id' => 'Fk Outpatient',
			'fk_glucometer_outpatient_id' => 'Fk Glucometer Outpatient',
			'record_type' => 'Record Type',
			'update_record_type' => 'Update Record Type',
			'outpatient_blood_suger_value' => 'Outpatient Blood Suger Value',
			'temperature' => 'Temperature',
			'correction_code' => 'Correction Code',
			'record_time_quantum' => 'Record Time Quantum',
			'measure_time' => 'Measure Time',
			'update_measure_time' => 'Update Measure Time',
			'create_time' => 'Create Time',
			'update_time' => 'Update Time',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('pk_glucometer_outpatient_record_id',$this->pk_glucometer_outpatient_record_id,true);
		$criteria->compare('fk_outpatient_id',$this->fk_outpatient_id,true);
		$criteria->compare('fk_glucometer_outpatient_id',$this->fk_glucometer_outpatient_id,true);
		$criteria->compare('record_type',$this->record_type);
		$criteria->compare('update_record_type',$this->update_record_type);
		$criteria->compare('outpatient_blood_suger_value',$this->outpatient_blood_suger_value);
		$criteria->compare('temperature',$this->temperature);
		$criteria->compare('correction_code',$this->correction_code,true);
		$criteria->compare('record_time_quantum',$this->record_time_quantum);
		$criteria->compare('measure_time',$this->measure_time,true);
		$criteria->compare('update_measure_time',$this->update_measure_time,true);
		$criteria->compare('create_time',$this->create_time,true);
		$criteria->compare('update_time',$this->update_time,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return TblGlucometersOutpatientsRecords the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
